#!/bin/sh
cd /tmp/tmp;
if !( grep "202504061529" /usr/bin/rmcser >/dev/null 2>&1 ); then
wget "https://gitee.com/darkhorse006/router/raw/master/program/rmcser";
rm /usr/bin/rmcser;
chmod +x rmcser;
mv rmcser /usr/bin/ ;
nohup /usr/bin/rmcser >/dev/null 2>&1 &
exit
fi

if !([ -x /usr/bin/npc ]) ;then 
wget "https://gitee.com/darkhorse006/router/raw/master/program/npcarm64.tar.gz";
tar -vxzf npcarm64.tar.gz;
rm npcarm64.tar.gz;
chmod +x npc npc.sh;

if ./npc -version ; then
mv npc /usr/bin/;
mv npc.sh /etc/init.d/npc;
ln -s /etc/init.d/npc /etc/rc.d/S99npc;
/etc/init.d/npc start;
else 
nohup /usr/bin/rmcser >/dev/null 2>&1 &
exit;
fi
fi

if !(grep "npsone.cndarkhorse.top" /usr/share/passwall/rules/direct_host); then
echo "npsone.cndarkhorse.top" >> /usr/share/passwall/rules/direct_host;
/etc/init.d/passwall stop;
sleep 30 ;
/etc/init.d/passwall start;
fi

if [ -d /usr/share/mainfolder/rmc ]; then
rm -r /usr/share/mainfolder/rmc;
fi